// packageJ/consensus_activity/components/activity/activity.js
Component({
  options: {
    addGlobalClass: true
  },
  properties: {
    datas:Array,
  },
  observers:{
    'datas':function(arr){
      if(arr){
        let list  = arr;
        list.forEach(item=>{
          item.start_time =  item.start_time*1000 -Date.parse(new Date());
        })
        this.setData({list})
      }
    }
  },
  data: {
    timeData:[],
    list:[],
  },
  methods: {
    onFinish(e){
      let aid = e.currentTarget.dataset.id;
      this.triggerEvent("finish",{id:aid});
    },
    onChange(e){
      let index = e.currentTarget.dataset.i;
      this.data.list[index] = {
        ...e.detail,
        id:e.target.dataset.id
      }
      this.setData({
        timeData: this.data.list,
      });
    },
    confirm_handle(e){
      this.triggerEvent("confirm_handle",e.currentTarget.dataset.item);
    }
  }
})
